<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
function getIp()
{
    global $ip;
    if (getenv("HTTP_CLIENT_IP"))
        $ip = getenv("HTTP_CLIENT_IP");
    else if (getenv("HTTP_X_FORWARDED_FOR"))
        $ip = getenv("HTTP_X_FORWARDED_FOR");
    else if (getenv("REMOTE_ADDR"))
        $ip = getenv("REMOTE_ADDR");
    else $ip = "Unknow IP";
    return $ip;
}

function typelist($type){
    switch ($type) {
        case 1:
            $xy = "内部公告";
            break;
        case 2:
            $xy ="外部公告";
            break;
    }
    return $xy;
}

function typetet($type){
    switch ($type) {
        case 1:
            $xy = "测试案例";
            break;
        case 2:
            $xy ="功能介绍";
            break;
    }
    return $xy;
}

function stubnt($type){
    switch ($type) {
        case 1:
            $yy = "未推送";
            break;
        case 2:
            $yy ="推送中";
            break;
    }
    return $yy;
}

function disa($type){
    switch ($type) {
        case 1:
            $mode = "启用";
            break;
        case 2:
            $mode ="禁用";
            break;
    }
    return $mode;
}

function opstion($type){
    switch ($type) {
        case 0:
            $ms = "管理员";
            break;
        case 1:
            $ms ="技术";
            break;
        case 2:
            $ms ="测试";
            break;
        case 3:
            $ms ="主管";
            break;
        case 4:
            $ms ="客服";
            break;
        case 5:
            $ms ="行政";
            break;
    }
    return $ms;
}

function stuste($type){
    switch ($type) {
        case 0:
            $m = "等待处理";
            break;
        case 1:
            $m ="技术已处理";
            break;
        case 2:
            $m ="测试通过";
            break;
        case 3:
            $m ="版本更新";
            break;
        case 4:
            $m ="处理完成";
            break;
        case 5:
            $m ="忽略";
            break;
    }
    return $m;
}
function stusteto($type){
    switch ($type) {
        case 0:
            $m = "等待处理";
            break;
        case 1:
            $m ="技术已处理";
            break;
        case 2:
            $m ="测试通过";
            break;
        case 3:
            $m ="处理完成";
            break;
        case 4:
            $m ="忽略";
            break;
    }
    return $m;
}
function jindu($type){
    switch ($type) {
        case 0:
            $m = "等待技术处理";
            break;
        case 1:
            $m ="等待测试";
            break;
        case 2:
            $m ="等待主管确认";
            break;
        case 3:
            $m ="等待客服确认";
            break;
        case 4:
            $m ="处理完成";
            break;
    }
    return $m;
}

function jinduto($type){
    switch ($type) {
        case 0:
            $m = "等待技术处理";
            break;
        case 1:
            $m ="等待测试";
            break;
        case 2:
            $m ="等待客服确认";
            break;
        case 3:
            $m ="处理完成";
            break;
    }
    return $m;
}
function warn($type){
    switch ($type) {
        case 1:
            $m ="正常";
            break;
        case 2:
            $m ="一般";
            break;
        case 3:
            $m ="严重";
            break;
    }
    return $m;
}
function groutime($type,$id){
    $position = Session::get('position','admin');
    switch ($type) {
        case 0:
            if($position==1 || $position==0 || $position==3){
                $m ="<button class='layui-btn layui-btn-normal layui-btn-mini'  data-action='grout' onclick='grouttime(this)' data-id=".$id.">点击设置</button>";
            }else{
                $m ="未设置";
            }

            break;
    }
    return $m;
}

//控制器加载layer弹窗
function alert_error($msg, $url)
{
    $str = '<script type="text/javascript" src="/static/js/inout/jquery-1.8.2.min.js"></script><script type="text/javascript" src="/static/plugins/layui/layui.js"></script>';
    $str .= '<script>
         layui.use([\'layer\'], function (){
               var layer = layui.layer;
              layer.alert(\'' . $msg . '\', {
              skin: \'layui-layer-demo\', //样式类名
              closeBtn: 0
              }, function(){
              window.location.href="' . $url . '";
              });
         });
        
  </script>';//主要方法
    return $str;
}
//控制器加载layer弹窗2
function alert_auth($msg)
{
    $str = '<script type="text/javascript" src="/static/js/inout/jquery-1.8.2.min.js"></script><script type="text/javascript" src="/static/plugins/layui/layui.js"></script>';
    $str .= '<script>
         layui.use([\'layer\'], function (){
               var layer = layui.layer;
              layer.alert(\'' . $msg . '\', {
              skin: \'layui-layer-demo\', //样式类名
              closeBtn: 0
              }, function(){

              });
         });
        
  </script>';//主要方法
    return $str;
}